package cn.zhf.shop.service.impl;

import cn.zhf.shop.entity.Message;
import cn.zhf.shop.entity.lesson.Lesson;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.zhf.shop.entity.Bank;
import cn.zhf.shop.mapper.BankMapper;
import cn.zhf.shop.service.BankService;

import java.util.List;

@Component
public class BankServiceImpl implements BankService{

    @Resource
    private BankMapper bankMapper;

    @Override
    public Message deleteByPrimaryKey(Integer bankId) {
        return Message.success(null).add(bankMapper.deleteByPrimaryKey(bankId)) ;
    }

    @Override
    public Message insert(Bank record) {
        return bankMapper.insert(record) > 0 ? Message.success(null) : Message.fail(null);
    }


    @Override
    public Message<Bank> selectByPrimaryKey(Integer bankId) {
        Bank refund=bankMapper.selectByPrimaryKey(bankId);
        return refund==null ? Message.fail("无记录"):Message.success(null).add(refund);
    }


    @Override
    public Message updateByPrimaryKey(Bank record) {
        return bankMapper.updateByPrimaryKey(record) > 0 ? Message.success("更新成功"+record.getBankId()):Message.fail("更新失败");
    }

    @Override
    public Message<List<Bank>> selectAll() {
        List<Bank> refund=bankMapper.selectAll();
        return refund==null ? Message.fail("无记录"):Message.success(null).add(refund);
    }

    @Override
    public Message<List<Bank>> search1(String str){
        return Message.success(null).add(bankMapper.selectBySearch1(str));
    }


}
